Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add verify feature #194

Merged
merged 13 commits into from
Feb 12, 2024
Merged

Add verify feature #194

merged 13 commits into from
Feb 12, 2024

Conversation

prxgr4mm3r
Copy link
Collaborator

No description provided.

Copy link
Contributor

@ipapandinas ipapandinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When building locally a flipper template contract, I am getting this error:

$ ../bin/run.js contract compile flipper --verifiable

Compiling flipper v0.1.0 (/tmp/cargo-contract_CoFkgq/contracts/flipper)
   Compiling metadata-gen v0.1.0 (/tmp/cargo-contract_CoFkgq/contracts/flipper/.ink/metadata_gen)
    Finished release [optimized] target(s) in 10m 47s
     Running `/contract/target/ink/flipper/release/metadata-gen`
 [==] Generating bundle
ERROR: Error decoding BuildResult:
 }
Caused by:
    expected value at line 1 column 1
Error Compiling flipper contract
    at ChildProcess.<anonymous> (file://~/Documents/dev/astar/swanky-cli/dist/commands/contract/compile.js:65:36)

I have the same dependencies as the Dockerimage:

  • cargo-contract: v4.0.0-rc.1
  • rust & toolchain: 1.72

When using the devcontainer I am also facing an error

root ➜ /workspaces/temp_project (main) $ ../bin/run.js contract compile flipper --verifiable
✖ Error Compiling flipper contract
error:   ProcessError: [==] Image does not exist. Pulling one from the registry
4.0.0-rc.1: Pulling from paritytech/contracts-verifiable 
1f3513f9501d: Pull complete
d2f5b4d64af6: Pull complete
50c38c4856e5: Pull complete
0bf705fe9e85: Pull complete
Digest: sha256:463b910e18793dd1f8f8e1c92ce72f8937892f8b657525573f47ae59545703e1
Status: Downloaded newer image for paritytech/contracts-verifiable:4.0.0-rc.1
ERROR: Docker responded with status code 500: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: waiting for init preliminary setup: read init-p: connection reset by peer: unknown
Error Compiling flipper contract
    at ChildProcess.<anonymous> (file:///workspaces/dist/commands/contract/compile.js:65:36)

Does it works well on your side @prxgr4mm3r ? How do you proceed to test it?

.devcontainer/devcontainer.json Outdated Show resolved Hide resolved

"image": "ghcr.io/swankyhub/swanky-cli/swanky-base:swanky3.1.0-beta.0_v2.1.1",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess your are using this feature to execute the official Parity image within the devcontainer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, is the verification working inside your devcontainer?

src/commands/contract/compile.ts Show resolved Hide resolved
src/commands/contract/verify.ts Outdated Show resolved Hide resolved
src/commands/contract/verify.ts Show resolved Hide resolved
src/commands/contract/compile.ts Outdated Show resolved Hide resolved
@ipapandinas
Copy link
Contributor

I am also wondering if these feature must be released once parity supports the --verifiable argument in a stable release, since the current one, 4.0.0-rc.1, is a release candidate @vsofiya

@prxgr4mm3r
Copy link
Collaborator Author

prxgr4mm3r commented Jan 10, 2024

@ipapandinas It works locally on my machine. I test it this way:

  1. I create a new swanky project
➜  swanky-cli git:(feature/verifiable) ✗ ../swanky-cli/bin/run.js init ../temp_proj
? Which contract template should we use initially? flipper
? What should we name your initial contract? flipper
? What is your name? prxgr4mm3r
? What is your email? 
? Do you want to download Swanky Node? Yes
✔ Copying common template files OK
✔ Checking dependencies OK
✔ Copying contract template files OK
✔ Processing templates OK
✔ Installing dependencies OK
✔ Initializing git OK
✔ Downloading Swanky node OK
✔ Writing config OK
🎉 😎 Swanky project successfully initialised! 😎 🎉

➜  swanky-cli git:(feature/verifiable) ✗ cd ../temp_proj 
  1. From temp_project folder run
➜  temp_proj git:(master) ✗ ../swanky-cli/bin/run.js contract compile flipper --verifiable

The contract was built in RELEASE mode.

Your contract artifacts are ready. You can find them in:
/home/prxgr4mm3r/RustroverProjects/temp_proj/target/ink/flipper

  - flipper.contract (code + metadata)
  - flipper.wasm (the contract's code)
  - flipper.json (the contract's metadata)
✔ flipper Contract compiled successfully
✔ Moving artifacts OK
✔ flipper contract's TS types Generated successfully
  1. Verify compiled contract
➜  temp_proj git:(master) ✗ ../swanky-cli/bin/run.js contract verify flipper       
✔ flipper Contract verified successfully

Can you try to build a contract without swanky-cli, just with cargo-contract, and let me know if it works on your side?

Copy link
Contributor

@ipapandinas ipapandinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured out my build issue and solve it with a fresh install of docker.
I tested your implementation and everything is working as expected, good job!
I just added few comments and I will check again later the design of the build object to make sure of the UX:

{
  timestamp: Date.now(),
  artifactsPath,
  verified: false,
}

src/commands/check/index.ts Outdated Show resolved Hide resolved
src/commands/check/index.ts Outdated Show resolved Hide resolved

"image": "ghcr.io/swankyhub/swanky-cli/swanky-base:swanky3.1.0-beta.0_v2.1.1",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, is the verification working inside your devcontainer?

src/commands/check/index.ts Outdated Show resolved Hide resolved
src/commands/contract/compile.ts Outdated Show resolved Hide resolved
src/commands/contract/compile.ts Show resolved Hide resolved
src/commands/contract/verify.ts Show resolved Hide resolved
src/commands/contract/verify.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@ipapandinas ipapandinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last adjustments

src/lib/tasks.ts Outdated Show resolved Hide resolved
src/lib/tasks.ts Outdated Show resolved Hide resolved
@ipapandinas ipapandinas mentioned this pull request Jan 18, 2024
Copy link
Contributor

@ipapandinas ipapandinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, good job! 🙌
@vsofiya

Copy link
Member

@pmikolajczyk41 pmikolajczyk41 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run the experiment locally and everything seems to be working well (both positive verification (similar steps as already presented in the discussion), and the negative one, when I changed contract code after verifiable build)

src/lib/tasks.ts Outdated Show resolved Hide resolved
.devcontainer/devcontainer.json Outdated Show resolved Hide resolved
src/commands/contract/compile.ts Outdated Show resolved Hide resolved
src/commands/contract/verify.ts Show resolved Hide resolved
src/commands/contract/verify.ts Show resolved Hide resolved
src/commands/contract/compile.ts Outdated Show resolved Hide resolved
@prxgr4mm3r prxgr4mm3r linked an issue Feb 7, 2024 that may be closed by this pull request
7 tasks
@ipapandinas ipapandinas changed the base branch from master to ink-devhub-1 February 12, 2024 12:07
@ipapandinas ipapandinas merged commit cd93607 into ink-devhub-1 Feb 12, 2024
3 checks passed
@ipapandinas ipapandinas deleted the feature/verifiable branch February 12, 2024 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add contract verify feature
4 participants